/*****************************************************************************
 *   Copyright (C) 2008 John Schember <john@nachtimwald.com>                 *
 *                                                                           *
 *   This file is part of niwbillmanager.                                    *
 *                                                                           *
 *   niwbillmanager is free software: you can redistribute it and/or         *
 *   modify it under the terms of the GNU General Public License as          *
 *   published by the Free Software Foundation, either version 3 of the      *
 *   License, or (at your option) any later version.                         *
 *                                                                           *
 *   niwbillmanager is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
 *   GNU General Public License for more details.                            *
 *                                                                           *
 *   You should have received a copy of the GNU General Public License       *
 *   along with niwbillmanager. If not, see                                  *
 *   <http://www.gnu.org/licenses/>.                                         *
 *****************************************************************************/

#ifndef REPORTWINDOW_H
#define REPORTWINDOW_H

#include <QDate>
#include <QHash>
#include <QList>
#include <QMainWindow>

#include <niwbillmanager.h>
#include "reportoptions.h"
#include "ui_reportwindow.h"

/**
 * Shows an html report based on the items and options inputed.
 * This window utalized Qt::WA_DeleteOnClose and does not need to be disposed
 * of manually.
 */
class ReportWindow : public QMainWindow, private Ui_ReportWindow
{
    Q_OBJECT

    public:
        ReportWindow();
        ~ReportWindow();

        void generateReport();

        void setDates(QList<QDate> dates);
        void setOptions(const ReportOptions &options);
        void setLib(NiwBillManager *lib=0);

    private slots:
        void on_actionSave_As_triggered();
        void on_actionPrint_Preview_triggered();
        void on_actionPrint_triggered();
        void on_actionFind_triggered();
        void on_actionZoom_In_triggered();
        void on_actionZoom_Out_triggered();
        void on_actionReset_Zoom_triggered();
        void findText(QString query, NiwFindWidget::NiwFindFlags flags);
        void hideFind();

    private:
        void connectSignals();
        QString generateChartJavascriptFunction(QString type, QString name,
            QHash<QString, double> data, QString divId);

        /**
         * This is used to append a count number to the window title.
         */
        static int instanceCount;

        QList<QDate> m_dates;
        ReportOptions m_options;
        NiwBillManager *m_lib;
};

#endif /* REPORTWINDOW_H */
